<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Flat UI</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Loading Bootstrap -->
    <link href="../assets/css/bootstrap.css" rel="stylesheet">

    <!-- Loading Flat UI -->
    <link href="../assets/css/flat-ui.css" rel="stylesheet">
    <link href="../assets/css/github.css" rel="stylesheet">
    <link rel="shortcut icon" href="../assets/images/favicon.ico">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <![endif]-->
  </head>
  <body>


    <div class="container">
      <div class="demo-headline">
        <h1 class="demo-logo">Lettuce
          <small>Behaviour Driven Development for python</small></h1>
      </div>
      <div class="row">
        <div class="span4">
          <div class="sidebar-nav">
            <ul class="share mrl">
              <div class="btn btn-primary btn-block btn-large">
                <h3>Sections</h3>
              </div>
              
              <a class="btn btn-inverse btn-block btn-large"
       href="#what-the-f---eature--">
         What the f** eature ?
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#features">
         Features
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#scenarios">
         Scenarios
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#simple">
         Simple
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#outlined">
         Outlined
    </a>
  
    
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#steps-and-its-definitions">
         Steps and its definitions
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#simple-steps">
         Simple steps
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#tabular-steps">
         Tabular steps
    </a>
  
    
  
    
  
              
            </ul>
          </div>
        </div>
        <div class="span8">
          <h1 id="what-the-f---eature--" name="what-the-f---eature--"><a href="#what-the-f---eature--">What the f** eature ?</a></h1>
<p>Unless you are used to Cucumber_ nomenclature, you may be wondering
about the terms that surround Lettuce concepts.</p>

<p>If this is your case, this introduction will guide you through the very
basic keywords that cover Lettuce.</p>
<h2 id="features" name="features"><a href="#features">Features</a></h2>
<p>Since Lettuce is used to test the behavior of a project, the behavior is
broken up in to features of the system.</p>

<p>After enumerating features, you need to create scenarios which will
describe those feature. Thus, scenarios are components of a feature.</p>

<p>Let&#39;s learn by example: suppose we want to create a system to manage a
address book.</p>

<p>OK, one of the very basic features of a address book is adding contacts,
which will include their name and phone numbers.</p>

<p>This is how Lettuce allows you to describe such feature:</p>
<div class="highlight"><pre name="what-the-f---eature---example-1"><span class="n">Feature</span><span class="o">:</span> <span class="n">Add</span> <span class="n">people</span> <span class="n">to</span> <span class="n">address</span> <span class="n">book</span>
  <span class="n">In</span> <span class="n">order</span> <span class="n">to</span> <span class="n">organize</span> <span class="n">phone</span> <span class="n">numbers</span> <span class="n">of</span> <span class="n">friends</span>
  <span class="n">As</span> <span class="n">a</span> <span class="n">wise</span> <span class="n">person</span>
  <span class="n">I</span> <span class="n">want</span> <span class="n">to</span> <span class="n">add</span> <span class="n">a</span> <span class="n">people</span> <span class="n">to</span> <span class="n">my</span> <span class="n">address</span> <span class="n">book</span>

  <span class="n">Scenario</span><span class="o">:</span> <span class="n">Add</span> <span class="n">a</span> <span class="n">person</span> <span class="k">with</span> <span class="n">name</span> <span class="n">and</span> <span class="n">phone</span> <span class="n">number</span>
    <span class="n">Given</span> <span class="n">I</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"John"</span>
    <span class="n">And</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"phone"</span> <span class="k">with</span> <span class="s2">"2233-4455"</span>
    <span class="n">When</span> <span class="n">I</span> <span class="n">save</span> <span class="n">the</span> <span class="n">data</span>
    <span class="n">Then</span> <span class="n">I</span> <span class="n">see</span> <span class="n">that</span> <span class="n">my</span> <span class="n">contact</span> <span class="n">book</span> <span class="n">has</span> <span class="n">the</span> <span class="n">persons</span><span class="o">:</span>
      <span class="o">|</span> <span class="n">name</span> <span class="o">|</span> <span class="n">phone</span>     <span class="o">|</span>
      <span class="o">|</span> <span class="n">John</span> <span class="o">|</span> <span class="mi">2233</span><span class="o">-</span><span class="mi">4455</span> <span class="o">|</span>

  <span class="n">Scenario</span><span class="o">:</span> <span class="n">Avoiding</span> <span class="n">a</span> <span class="n">invalid</span> <span class="n">phone</span> <span class="n">number</span>
    <span class="n">Given</span> <span class="n">I</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"John"</span>
    <span class="n">And</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"phone"</span> <span class="k">with</span> <span class="s2">"000"</span>
    <span class="n">When</span> <span class="n">I</span> <span class="n">save</span> <span class="n">the</span> <span class="n">data</span>
    <span class="n">Then</span> <span class="n">I</span> <span class="kd">get</span> <span class="n">the</span> <span class="n">error</span><span class="o">:</span> <span class="s2">"000 is a invalid phone number"</span>
</pre></div>
<p>In the feature above we can notice a few elements, for instance:</p>

<blockquote>
<ul>
<li>  The feature name:</li>
</ul>

<!-- -->
<div class="highlight"><pre name="what-the-f---eature---example-2"><span class="n">Feature</span><span class="o">:</span> <span class="n">Add</span> <span class="n">people</span> <span class="n">to</span> <span class="n">contact</span> <span class="n">book</span>
</pre></div>
<ul>
<li>  Feature headline:</li>
</ul>

<!-- -->
<div class="highlight"><pre name="what-the-f---eature---example-3"><span class="n">In</span> <span class="n">order</span> <span class="n">to</span> <span class="n">organize</span> <span class="n">phone</span> <span class="n">numbers</span> <span class="n">of</span> <span class="n">friends</span>
<span class="n">As</span> <span class="n">a</span> <span class="n">wise</span> <span class="n">person</span>
<span class="n">I</span> <span class="n">want</span> <span class="n">to</span> <span class="n">add</span> <span class="n">a</span> <span class="n">people</span> <span class="n">to</span> <span class="n">my</span> <span class="n">address</span> <span class="n">book</span>
</pre></div>
<ul>
<li>  Scenarios:</li>
</ul>

<!-- -->
<div class="highlight"><pre name="what-the-f---eature---example-4"><span class="n">Scenario</span><span class="o">:</span> <span class="n">Add</span> <span class="n">a</span> <span class="n">person</span> <span class="k">with</span> <span class="n">name</span> <span class="n">and</span> <span class="n">phone</span>
  <span class="n">Given</span> <span class="n">I</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"John"</span>
  <span class="n">And</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"phone"</span> <span class="k">with</span> <span class="s2">"2233-4455"</span>
  <span class="n">When</span> <span class="n">I</span> <span class="n">save</span> <span class="n">the</span> <span class="n">data</span>
  <span class="n">Then</span> <span class="n">I</span> <span class="n">see</span> <span class="n">that</span> <span class="n">my</span> <span class="n">contact</span> <span class="n">book</span> <span class="n">has</span> <span class="n">the</span> <span class="n">persons</span><span class="o">:</span>
    <span class="o">|</span> <span class="n">name</span> <span class="o">|</span> <span class="n">phone</span>     <span class="o">|</span>
    <span class="o">|</span> <span class="n">John</span> <span class="o">|</span> <span class="mi">2233</span><span class="o">-</span><span class="mi">4455</span> <span class="o">|</span>

<span class="n">Scenario</span><span class="o">:</span> <span class="n">Avoiding</span> <span class="n">a</span> <span class="n">invalid</span> <span class="n">phone</span> <span class="n">number</span>
  <span class="n">Given</span> <span class="n">I</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"John"</span>
  <span class="n">And</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"phone"</span> <span class="k">with</span> <span class="s2">"000"</span>
  <span class="n">When</span> <span class="n">I</span> <span class="n">save</span> <span class="n">the</span> <span class="n">data</span>
  <span class="n">Then</span> <span class="n">I</span> <span class="kd">get</span> <span class="n">the</span> <span class="n">error</span><span class="o">:</span> <span class="s2">"000 is a invalid phone number"</span>
</pre></div></blockquote>
<h2 id="scenarios" name="scenarios"><a href="#scenarios">Scenarios</a></h2>
<p>One or more scenarios compose a feature. There are two kinds of
scenarios:</p>
<h3 id="simple" name="simple"><a href="#simple">Simple</a></h3>
<p>The simple scenarios are composed by steps, no matter if they are simple
or tabulated steps.</p>

<p>The feature above is composed by two simple scenarios.</p>
<h3 id="outlined" name="outlined"><a href="#outlined">Outlined</a></h3>
<p>Outlined scenarios are very handy because they help you to avoid
repetition.</p>

<p>Suppose that we need to fill the same form many times, each time with a
different data set. This is how it could be done using scenario
outlines:</p>

<p>Let&#39;s see how it could be done with scenario outlines:</p>
<div class="highlight"><pre name="what-the-f---eature---example-5"><span class="n">Feature</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">all</span> <span class="n">my</span> <span class="n">friends</span> <span class="n">to</span> <span class="n">attend</span> <span class="n">a</span> <span class="n">conference</span>
  <span class="n">In</span> <span class="n">order</span> <span class="n">to</span> <span class="n">apply</span> <span class="n">all</span> <span class="n">my</span> <span class="n">friends</span> <span class="n">to</span> <span class="n">the</span> <span class="n">next</span> <span class="n">PyCon_</span>
  <span class="n">As</span> <span class="n">a</span> <span class="n">lazy</span> <span class="n">person</span>
  <span class="n">I</span> <span class="n">want</span> <span class="n">to</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">same</span> <span class="n">form</span> <span class="n">many</span> <span class="n">times</span>

  <span class="n">Scenario</span> <span class="n">Outline</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">my</span> <span class="n">friends</span>
    <span class="n">Go</span> <span class="n">to</span> <span class="n">the</span> <span class="n">conference</span> <span class="n">website</span>
    <span class="n">Access</span> <span class="n">the</span> <span class="n">link</span> <span class="s2">"I will attend"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"&lt;friend_name&gt;"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"email"</span> <span class="k">with</span> <span class="s2">"&lt;friend_email&gt;"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"birthday"</span> <span class="k">with</span> <span class="s2">"&lt;friend_birthdate&gt;"</span>
    <span class="n">Click</span> <span class="n">on</span> <span class="s2">"confirm attendance"</span> <span class="n">button</span>

  <span class="n">Examples</span><span class="o">:</span>
    <span class="o">|</span> <span class="n">friend_name</span> <span class="o">|</span> <span class="n">friend_email</span>         <span class="o">|</span> <span class="n">friend_birthdate</span> <span class="o">|</span>
    <span class="o">|</span> <span class="n">Mary</span>        <span class="o">|</span> <span class="n">mary</span><span class="err">@</span><span class="n">domain</span><span class="o">.</span><span class="na">com</span>      <span class="o">|</span> <span class="mi">1988</span><span class="sr">/02/</span><span class="mi">10</span>       <span class="o">|</span>
    <span class="o">|</span> <span class="n">Lincoln</span>     <span class="o">|</span> <span class="n">lincoln</span><span class="err">@</span><span class="n">provider</span><span class="o">.</span><span class="na">net</span> <span class="o">|</span> <span class="mi">1987</span><span class="sr">/09/</span><span class="mi">10</span>       <span class="o">|</span>
    <span class="o">|</span> <span class="n">Marcus</span>      <span class="o">|</span> <span class="n">marcus</span><span class="err">@</span><span class="n">other</span><span class="o">.</span><span class="na">org</span>     <span class="o">|</span> <span class="mi">1990</span><span class="sr">/10/</span><span class="mi">05</span>       <span class="o">|</span>
</pre></div>
<p>In a nutshell, the scenario above is equivalent to write the huge code
bellow</p>
<div class="highlight"><pre name="what-the-f---eature---example-6"><span class="n">Feature</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">all</span> <span class="n">my</span> <span class="n">friends</span> <span class="n">to</span> <span class="n">attend</span> <span class="n">a</span> <span class="n">conference</span>
  <span class="n">In</span> <span class="n">order</span> <span class="n">to</span> <span class="n">apply</span> <span class="n">all</span> <span class="n">my</span> <span class="n">friends</span> <span class="n">to</span> <span class="n">the</span> <span class="n">next</span> <span class="n">PyCon_</span>
  <span class="n">As</span> <span class="n">a</span> <span class="n">lazy</span> <span class="n">person</span>
  <span class="n">I</span> <span class="n">want</span> <span class="n">to</span> <span class="n">fill</span> <span class="n">the</span> <span class="n">same</span> <span class="n">form</span> <span class="n">many</span> <span class="n">times</span>

  <span class="n">Scenario</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">Mary</span>
    <span class="n">Go</span> <span class="n">to</span> <span class="n">the</span> <span class="n">conference</span> <span class="n">website</span>
    <span class="n">Access</span> <span class="n">the</span> <span class="n">link</span> <span class="s2">"I will attend"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"Mary"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"email"</span> <span class="k">with</span> <span class="s2">"mary@domain.com"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"birthday"</span> <span class="k">with</span> <span class="s2">"1988/02/10"</span>
    <span class="n">Click</span> <span class="n">on</span> <span class="s2">"confirm attendance"</span> <span class="n">button</span>

  <span class="n">Scenario</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">Lincoln</span>
    <span class="n">Go</span> <span class="n">to</span> <span class="n">the</span> <span class="n">conference</span> <span class="n">website</span>
    <span class="n">Access</span> <span class="n">the</span> <span class="n">link</span> <span class="s2">"I will attend"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"Lincoln"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"email"</span> <span class="k">with</span> <span class="s2">"lincoln@provider.net"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"birthday"</span> <span class="k">with</span> <span class="s2">"1987/09/10"</span>
    <span class="n">Click</span> <span class="n">on</span> <span class="s2">"confirm attendance"</span> <span class="n">button</span>

  <span class="n">Scenario</span><span class="o">:</span> <span class="n">Apply</span> <span class="n">Marcus</span>
    <span class="n">Go</span> <span class="n">to</span> <span class="n">the</span> <span class="n">conference</span> <span class="n">website</span>
    <span class="n">Access</span> <span class="n">the</span> <span class="n">link</span> <span class="s2">"I will attend"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"name"</span> <span class="k">with</span> <span class="s2">"Marcus"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"email"</span> <span class="k">with</span> <span class="s2">"marcus@other.org"</span>
    <span class="n">Fill</span> <span class="n">the</span> <span class="n">field</span> <span class="s2">"birthday"</span> <span class="k">with</span> <span class="s2">"1990/10/05"</span>
    <span class="n">Click</span> <span class="n">on</span> <span class="s2">"confirm attendance"</span> <span class="n">button</span>
</pre></div>
<p>As you can notice, scenario outlines are very useful and help you on
avoiding text and code repetition</p>
<h2 id="steps-and-its-definitions" name="steps-and-its-definitions"><a href="#steps-and-its-definitions">Steps and its definitions</a></h2>
<p>Comparable with Scenarios, Steps comes in two kinds:</p>
<h3 id="simple-steps" name="simple-steps"><a href="#simple-steps">Simple steps</a></h3>
<p>Simple steps are actually simple and they are related to the step
definitions inside the scenarios.</p>

<p>Lettuce considers each line of a scenario as a simple step. The only
exception is if the first non-blank character of the line is a pipe <code>|</code>.
In this case, Lettuce will consider the step as a tabular step.</p>

<p>For instance, a simple step may look like this:</p>
<div class="highlight"><pre name="what-the-f---eature---example-7"><span class="n">Given</span> <span class="n">I</span> <span class="n">go</span> <span class="n">to</span> <span class="n">the</span> <span class="n">conference</span> <span class="n">website</span>
</pre></div><h3 id="tabular-steps" name="tabular-steps"><a href="#tabular-steps">Tabular steps</a></h3>
<p>Analog to Outlined Scenarios, the tabular steps are very useful, and
avoid repetition of text.</p>

<p>Tabular steps are specially useful to set up some data set in a
scenario, or to compare a set of data to the expected results in the end
of the scenario.</p>

<p>However, feel free to use this whenever you find it useful.</p>

<p>Example:</p>
<div class="highlight"><pre name="what-the-f---eature---example-8"><span class="n">Given</span> <span class="n">I</span> <span class="n">have</span> <span class="n">the</span> <span class="n">following</span> <span class="n">contacts</span> <span class="n">in</span> <span class="n">my</span> <span class="n">database</span>
  <span class="o">|</span> <span class="n">name</span>  <span class="o">|</span> <span class="n">phone</span>      <span class="o">|</span>
  <span class="o">|</span> <span class="n">John</span>  <span class="o">|</span> 2233<span class="o">-</span>4455  <span class="o">|</span>
  <span class="o">|</span> <span class="n">Smith</span> <span class="o">|</span> 9988<span class="o">-</span>7766  <span class="o">|</span>
</pre></div>
        </div>
      </div>
    </div> <!-- /container -->

    <footer>
      <div class="container">
        <div class="row">
          <div class="span7">
            <h3 class="footer-title">Lettuce</h3>
            <p>Lettuce is maintained by gabrielfalcao. <br />
              This documentation was generated automatically by <a href="http://octomarks.io/gabrielfalcao/markment">Markment</a>.
            </p>
            <p>
              This theme was written by Gabriel Falcão using the <a href="http://designmodo.github.io/Flat-UI/">Flat-UI</a> library by
              <a class="footer-brand" href="http://designmodo.com" target="_blank">
                <img src="../assets/images/footer/logo.png" alt="Designmodo.com">
              </a>
            </p>
          </div> <!-- /span8 -->

          <div class="span5">
            <div class="footer-banner">
              <h3 class="footer-title">Table of contents</h3>
              <ul>
                 
                <li>
                  <a href="../contents.html">
                        contents.md
                  </a>
                </li>
                 
                <li>
                  <a href="../index.html">
                        index.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/documentation.html">
                        documentation.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/index.html">
                        index.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/install-debian-squeeze.html">
                        install-debian-squeeze.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/install.html">
                        install.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/testing.html">
                        testing.md
                  </a>
                </li>
                 
                <li>
                  <a href="./install.html">
                        install.md
                  </a>
                </li>
                 
                <li>
                  <a href="./overview.html">
                        overview.md
                  </a>
                </li>
                 
                <li>
                  <a href="./wtf.html">
                        wtf.md
                  </a>
                </li>
                 
                <li>
                  <a href="../recipes/django-lxml.html">
                        django-lxml.md
                  </a>
                </li>
                 
                <li>
                  <a href="../recipes/nose.html">
                        nose.md
                  </a>
                </li>
                 
                <li>
                  <a href="../reference/cli.html">
                        cli.md
                  </a>
                </li>
                 
                <li>
                  <a href="../reference/features.html">
                        features.md
                  </a>
                </li>
                 
                <li>
                  <a href="../reference/languages.html">
                        languages.md
                  </a>
                </li>
                 
                <li>
                  <a href="../reference/terrain.html">
                        terrain.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/django.html">
                        django.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/multiline.html">
                        multiline.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/scenario-outlines.html">
                        scenario-outlines.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/simple.html">
                        simple.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/steps-from-step-definitions.html">
                        steps-from-step-definitions.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/tables.html">
                        tables.md
                  </a>
                </li>
                 
              </ul>
            </div>
          </div>
        </div>
      </div>
    </footer>
  </body>
</html>